package com.gongj.lifecycle;

import org.springframework.context.SmartLifecycle;
import org.springframework.stereotype.Component;

//@Component
public class CustomizeSmartLifecycle implements SmartLifecycle {

	private volatile boolean running = false;

	@Override
	public void start() {
		running = true;
		System.out.println("CustomizeSmartLifecycle start()");
	}

	@Override
	public void stop() {
		System.out.println("CustomizeSmartLifecycle stop()");
		running = false;
	}

	@Override
	public boolean isRunning() {
		System.out.println("CustomizeSmartLifecycle isRunning() ==== " + running);
		return running;
	}

	@Override
	public boolean isAutoStartup() {
		return true;
	}

//	@Override
//	public void stop(Runnable callback) {
//		System.out.println("CustomizeSmartLifecycle stop(Runnable callback)");
//		SmartLifecycle.super.stop(callback);
//	}
	@Override
	public void stop(Runnable callback) {

		System.out.println("CustomizeSmartLifecycle stop(Runnable callback)");
		//stop();
		//callback.run();
	}

	@Override
	public int getPhase() {
		return 1;
	}
}
